# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-base

pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}0.10"
pkgver=0.10.36
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="https://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-libvorbis"
    "${MINGW_PACKAGE_PREFIX}-libtheora"
    "${MINGW_PACKAGE_PREFIX}-pango"
    #"${MINGW_PACKAGE_PREFIX}-gobject-introspection"
    #"${MINGW_PACKAGE_PREFIX}-libvisual"
    #"${MINGW_PACKAGE_PREFIX}-cdparanoia"
    "${MINGW_PACKAGE_PREFIX}-gstreamer0.10"
    "${MINGW_PACKAGE_PREFIX}-orc"
    )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
    fix-crash-0-byte-ogg.patch
        colorbalance-fix-abi.patch
        revert-decodebin-playbin-removal.patch
        videoscale-fix-negotiation.patch
        ayuv64-lanczos.patch
        gstaudio-symbols.patch
    gst-plugins-base-0.10.36-warnings.patch
    gst-plugins-base-0.10.28-gnomevfswin32.patch
    0001-fix-test-compilation.mingw.patch
    0002-fix-test-running.mingw.patch
    0003-fix-riff-includes.mingw.patch
    0004-fix-X-detection.mingw.patch)

sha256sums=('1fe45c3894903001d4d008b0713dab089f53726dcb5842d5b40c2595a984e64a'
            'a6a01035ea9627737f9c17f72919857ed43ccc7c2cb08b645b43ed89f78d0f4f'
            '7442c5c68068428b8c7ac1d3825ce29f1bb152b75b77047b9e806c7d322b780c'
            'ba20659fafea73db016ddaecd128f12087e0957ce35cf2c3ce29f72c51551ef3'
            'ae27f7be58997217f67898b37b138a485c203389e56b65e6b31c23f769ef39ca'
            '3792dfe80c69f51c0db98533e8fb16707b5dd2ee6933ea6098583af873ceb44a'
            '56e7a988df39d2ec4befa265536ad8c30d3c8d18d136cebef64e8d6baac1abae'
            '92781406aab464a6749c7c8768d19f7a377062ea66b4c25b4b1c0096c4451b98'
            'fd38e9e7a86cc095a6caa8a83302ca2f1079a8eb8aacac258103d8873c866f07'
            'ddd4769e187dfdb2845758ffde2fb76b2cec5e5f48c161fd9d0243d4b9f19077'
            'c22c1b12c6168278398622c8c60b1d641aaf4832305589da76e0c40c75b253e8'
            'b348aed490aa1172bb24eafb32cef45517b9087a4a8bc1f8904983452f81aa42'
            'a6d8f5af38a99be158375495628231cdbf3e5273d78589891070c8c2ccc3be48')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}

  sed -i -e '/AC_PATH_XTRA/d' -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac
  patch -Np1 -i ${srcdir}/fix-crash-0-byte-ogg.patch
  patch -Np1 -i ${srcdir}/colorbalance-fix-abi.patch
  patch -Np1 -i ${srcdir}/ayuv64-lanczos.patch
  patch -Np1 -i ${srcdir}/videoscale-fix-negotiation.patch
  patch -Np1 -i ${srcdir}/gstaudio-symbols.patch
  #patch  -Rp1 -i ${srcdir}/revert-decodebin-playbin-removal.patch

  patch -Np0 -i ${srcdir}/gst-plugins-base-0.10.36-warnings.patch
  patch -Np1 -i ${srcdir}/gst-plugins-base-0.10.28-gnomevfswin32.patch

  patch -p1 -i ${srcdir}/0001-fix-test-compilation.mingw.patch
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  patch -p1 -i ${srcdir}/0003-fix-riff-includes.mingw.patch
  patch -p1 -i ${srcdir}/0004-fix-X-detection.mingw.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc \
    --disable-vorbistest \
    --disable-freetypetest \
    --disable-examples
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer-*/*.a
}
